﻿@{
    ViewBag.Title = "showmember";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<script src="~/Scripts/jquery-1.8.2.min.js"></script>


<script>
   $(document).ready(function () {
       $.ajax({
           url: "/Home/ShowMember1",
           type: "get",
           success: function (data) {

               $(data).each(function (index, item) {
                   var p = "<tr><td>" + item.Mid +
                       "</td><td>" + item.Mname +
                       "</td><td>" + item.Mpassword +
                       "</td><td>" + item.NickName +
                       "</td><td>" + item.RealName +
                       "</td><td>" + item.Sex +
                       "</td><td>" + item.Tel +
                       "</td><td>" +
                       "<input type='button' value='删除' onclick='DeleteMember(" + item.Mid + " )' />" + "</td></tr>"
                   $("#table1").append(p);
                   
               })                            
           }
       })
   })
  
   //删除
   function DeleteMember(obj) {
     
       //var m_id = $("#tr :td").val();

       if (confirm("你确定要删除么?")) {
           $.ajax({
               url: "/Home/DeleteMember",
               type: "post",
               data: {
                   Mid: obj
               },   
               "success": function (data) {
                   if (data == 1) {
                       //$(obj).parent().parent().remove();
                       alert("删除成功！");
                       location.href = "/Home/showmember";
                   }
               }

           })
       }
       //var Mid = $(obj).attr("data-mid");   
   }
   //增加方法
   function Add() {
       location.href = '/Home/AddPro_Member'
   }
    //删除
    //"success": function (obj) {               
    //    var data = eval("(" + obj + ")");
    //    alert("data");
    //    $("#table1 tr:gt(0)").remove()
    //    for (var i = 0; i < data.rows.length; i++) {
    //        var mid = data.rows[i].Mid;
    //        var tr = "<tr>";
    //        tr += "<td>" + data.rows[i].Mname + "</td>";
    //        tr += "<td>" + data.rows[i].Mpasswod + "</td>";
    //        tr += "<td>" + data.rows[i].NickName + "</td>";
    //        tr += "<td>" + data.rows[i].RealName + "</td>";
    //        tr += "<td>" + data.rows[i].Sex + "</td>";
    //        tr += "<td>" + data.rows[i].Tel + "</td>";
    //        tr += "<td>";
    //        tr += "<input type='button' value='删除' onclick='DeleteMember(this)' attr-did=" + mid + "  />";
    //        tr += "</td>";
    //        tr += "</tr>";

    //        $("#table1").append(tr);
    //    }
    //}
</script>

<center>
<h2>会员列表显示</h2>
    <input id="Button1" type="button" value="添加" onclick="Add()" />
<table id="table1">
    <tr>
        <td>会员编号</td>
        <td>会员账号</td>
        <td>会员密码</td>
        <td>昵称</td>
        <td>真实姓名</td>
        <td>性别</td>
        <td>手机号</td>
    </tr>
</table>
</center>
